package crud

import (
	"encoding/json"

	"cms/system/cmd"
	"cms/system/helper"
)

type NameSpace struct {
	Controller string
	Validate   string
	Service    string
	Model      string
}

type AppClass struct {
	Controller   string
	Service      string
	Model        string
	ValidateAdd  string
	ValidateEdit string
}

type AppFiles struct {
	Controller   string // 控制器
	ValidateAdd  string // 验证器
	ValidateEdit string
	Service      string
	Model        string // 模型
	Js           string
	HtmlAdd      string
	HtmlEdit     string
	HtmlIndex    string
}

type AppPath struct {
	ModelPath      string
	ValidatePath   string
	ControllerPath string
	ServicePath    string
	JsPath         string
	HtmlPath       string
}

type cGlobal struct {
	Ds          string
	Name        string
	RootPath    string
	TableName   string
	ModuleName  string
	HtmlURI     string
	JsURI       string
	JsURLPath   string
	Suffix      string
	Class       string
	HasModel    bool
	OnlyIndex   bool
	TableSchema []cmd.MapStr
	Field       cmd.MMapStr
	Pid         int

	AppClass  *AppClass
	NameSpace *NameSpace
	AppPath   *AppPath
	AppFiles  *AppFiles
}

func (g *cGlobal) String() string {
	by, _ := json.Marshal(*g)

	return string(by)
}

func (c *cGlobal) Print() {
	helper.Print(c)
}
